package practice;

/**
 * @author ：wangchao
 * @version ：V1.0
 * @program ：MySpringCloud
 * @date ：Created in 2020/10/9 11:28
 * @description ：int转byte数组
 */
public class Int2ByteArr {

    public static void main(String[] args) {
        byte[] bytes = toLH(5);
        System.out.println(bytes);
    }

    public static byte[] toLH(int n) {
        byte[] b = new byte[4];
        b[3] = (byte) (n & 0xff);
        b[2] = (byte) (n >> 8 & 0xff);
        b[1] = (byte) (n >> 16 & 0xff);
        b[0] = (byte) (n >> 24 & 0xff);
        return b;
    }
}